//
//  ARTPhoneJudgeManager.m
//  ChartsDemo
//
//  Created by Kary on 2022/12/1.
//

#import "ARTPhoneJudgeManager.h"

@implementation ARTPhoneJudgeManager


+ (instancetype)shareManager {
    static ARTPhoneJudgeManager *manager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        manager = [[ARTPhoneJudgeManager alloc] init];
    });
    return manager;
}

- (instancetype)init {
    self = [super init];
    if (self) {
        [self executePhoneJudge];
    }
    return self;
}

- (void)executePhoneJudge {
    self.iPhoneXSeries = [self getIsIPhoneXSeries];
}

- (BOOL)getIsIPhoneXSeries {
    BOOL iPhoneXSeries = NO;
    if (UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPhone) {
        return iPhoneXSeries;
    }
    if (@available(iOS 11.0, *)) {
        UIWindow *mainWindow = [[[UIApplication sharedApplication] delegate] window];
        if (mainWindow.safeAreaInsets.bottom > 0.0) {
            iPhoneXSeries = YES;
        }
    }
    return iPhoneXSeries;
}

@end
